import urllib.request
import urllib.error


def urlError():
    req = urllib.request.Request('https://www.hellodylandasdasd.cn/fuck')
    try:
        urllib.request.urlopen(req)
    except urllib.error.URLError as e:
        print('错误信息：', e)


# HTTPError 是 URLError的子类
def httpError():
    req2 = urllib.request.Request('https://www.hellodylan.cn/hehe')
    try:
        urllib.request.urlopen(req2)
    except urllib.error.HTTPError as e:
        print('状态码：', e)  # HTTP Error 404:
        print('页面信息：', e.read())


urlError()
# httpError()
